<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h2>在事件中调用函数</h2>
		<button onclick="hello()">调用hello()</button>
		<h2>在链接中调用函数</h2>
		<a href="javascript:hello();">调用hello()</a>
		<h2>带参数的函数</h2>
		<input type="text" id="input1" />+
		<input type="text" id="input2" /><button onclick="calc()">=</button>
		<input type="text" id="input3" />

		<script>
			//定义函数
			function hello {
				console.log("Hello world!");
			}
			//在script标签中调用函数
			hello();

			function add(a, b) {
				c = a + b;
				return c;
			}

			function calc() {
				num1 = parseInt(input1.value);
				num2 = parseInt(input2.value);
				input3.value = add(num1, num2);
			}
			var add2 = function(a, b) {
				return a + b;
			}

			var add3 = new Function("a", "b", "return a+b");
		</script>
	</body>
</html>
